/****** Object:  Table [dbo].[NotarialForm]    Script Date: 12/26/2011 01:02:45 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[NotarialForm](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [bigint] NOT NULL,
	[OrderId] [int] NULL,
	[StatusId] [int] NOT NULL,
	[RangeId] [int] NOT NULL,
	[SerialNumberId] [int] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[EndDate] [datetime] NULL,
	[IsInAct] [bit] NOT NULL,
	[IsInEnot] [bit] NOT NULL,
	[UserId] [int] NOT NULL,
	[Comment] [nchar](1000) NULL,
	[ModifyDate] [datetime] NOT NULL,
	[Search] [nchar](50) NULL,
 CONSTRAINT [PK_NotarialForm] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[NotarialForm]  WITH CHECK ADD  CONSTRAINT [FK_NotarialForm_NotarialFormRange] FOREIGN KEY([RangeId])
REFERENCES [dbo].[NotarialFormRange] ([Id])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[NotarialForm] CHECK CONSTRAINT [FK_NotarialForm_NotarialFormRange]
GO

ALTER TABLE [dbo].[NotarialForm]  WITH CHECK ADD  CONSTRAINT [FK_NotarialForm_NotarialFormSerialNumber] FOREIGN KEY([SerialNumberId])
REFERENCES [dbo].[NotarialFormSerialNumber] ([Id])
GO

ALTER TABLE [dbo].[NotarialForm] CHECK CONSTRAINT [FK_NotarialForm_NotarialFormSerialNumber]
GO

ALTER TABLE [dbo].[NotarialForm]  WITH CHECK ADD  CONSTRAINT [FK_NotarialForm_NotarialFormStatus] FOREIGN KEY([StatusId])
REFERENCES [dbo].[NotarialFormStatus] ([Id])
GO

ALTER TABLE [dbo].[NotarialForm] CHECK CONSTRAINT [FK_NotarialForm_NotarialFormStatus]
GO

ALTER TABLE [dbo].[NotarialForm]  WITH CHECK ADD  CONSTRAINT [FK_NotarialForm_Order] FOREIGN KEY([OrderId])
REFERENCES [dbo].[Order] ([Id])
GO

ALTER TABLE [dbo].[NotarialForm] CHECK CONSTRAINT [FK_NotarialForm_Order]
GO

ALTER TABLE [dbo].[NotarialForm]  WITH CHECK ADD  CONSTRAINT [FK_NotarialForm_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO

ALTER TABLE [dbo].[NotarialForm] CHECK CONSTRAINT [FK_NotarialForm_User]
GO

ALTER TABLE [dbo].[NotarialForm] ADD  CONSTRAINT [DF_NotarialForm_SerialNumberId]  DEFAULT ((1)) FOR [SerialNumberId]
GO

ALTER TABLE [dbo].[NotarialForm] ADD  CONSTRAINT [DF_NotarialForm_CreateDate]  DEFAULT (getdate()) FOR [CreateDate]
GO

ALTER TABLE [dbo].[NotarialForm] ADD  CONSTRAINT [DF_NotarialForm_IsInAct]  DEFAULT ((0)) FOR [IsInAct]
GO

ALTER TABLE [dbo].[NotarialForm] ADD  CONSTRAINT [DF_NotarialForm_IsInEnot]  DEFAULT ((0)) FOR [IsInEnot]
GO

ALTER TABLE [dbo].[NotarialForm] ADD  CONSTRAINT [DF_NotarialForm_ModifyDate]  DEFAULT (getdate()) FOR [ModifyDate]
GO


